function [fc, fc_prod] = ...
    compute_fc(n_config, config_binary, ...
    brewer_name_by_owner, prod_id_by_owner, fixed_prod_ind_id, ...
    fixed_prod_entry_m, fc_first, prod_sim_fc, nfc)
%fc: total fc for each owner; fc_prod: fc for each product

n_owner = length(config_binary);
fc = nan(n_owner, 1);
for no = 1 : n_owner    
    if ~isempty(prod_sim_fc{no})
        fc(no) = sum(prod_sim_fc{no}(config_binary{no}>0, nfc))+...
            length(unique(brewer_name_by_owner{no}(config_binary{no}>0)))*fc_first;
    end    
end

if nargout > 1
    fc_prod = nan(n_config, 1);
    config = false(n_config, 1);
    for no = 1 : n_owner    
        in_mkt_id_no = prod_id_by_owner{no}(config_binary{no}>0);
        if ~isempty(in_mkt_id_no)        
            fc_prod(in_mkt_id_no) = prod_sim_fc{no}(config_binary{no}>0, nfc) +...
                length(unique(brewer_name_by_owner{no}(config_binary{no}>0)))*fc_first/length(in_mkt_id_no);%spread the scope parameter across products
            config(in_mkt_id_no) = true;
        end
    end
    
    config(fixed_prod_ind_id) = fixed_prod_entry_m>0;
    
    fc_prod(fixed_prod_ind_id) = nan;
    fc_prod = fc_prod(config);
end



